package com.bms.actions;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

import com.bms.utils.DB;
import com.opensymphony.xwork2.ActionSupport;

public class RegisterAction extends ActionSupport{

	private String firstname;
	private String usermail;
	private String password;
	private String mobilenumber;
	
	public String getFirstname() {
		return firstname;
	}
	public void setFirstname(String firstname) {
		this.firstname = firstname;
	}
	public String getUsermail() {
		return usermail;
	}
	public void setUsermail(String usermail) {
		this.usermail = usermail;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public String getMobilenumber() {
		return mobilenumber;
	}
	public void setMobilenumber(String mobilenumber) {
		this.mobilenumber = mobilenumber;
	}
	public String execute(){
			Connection con;
			try{
				con =  DB.getConnection();
				PreparedStatement stmt = con.prepareStatement("insert into user(firstname,emailid,pwd,mobilenumber) values(?,?,?,?)");
				stmt.setString(1, firstname);
				stmt.setString(2, usermail);
				stmt.setString(3, password);
				stmt.setString(4, mobilenumber);
				System.out.println("username : " + firstname +" emailId : " + usermail +" password : "+password+" mobilenumber : "+mobilenumber);
				stmt.executeUpdate();
				con.close();
			}
			catch(Exception e){
				System.out.println(e);
			}
	return SUCCESS;
	}
}
